<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */


//判断是否已安装
if(!is_file("./install/lock") && is_file("./install/index.php")){
	@header("location:install/index.php");
}
include 'data/weby.php';
?>
<?php
include 'head.php';
?>
      <div class="lyear-layout-sidebar-scroll"> 
        
        <nav class="sidebar-main">
          <ul class="nav nav-drawer">
            <li class="nav-item"> 
            <a href="index.php">
            <i class="mdi mdi-home"></i> 首页</a> 
            </li>
            <li class="nav-item"> 
            <a href="dlqq.php">
            <i class="mdi mdi-account"></i> 代理查询</a> 
            </li>
            <li class="nav-item"> 
            <a href="buy.php">
            <i class="mdi mdi-arrow-down-bold"></i> 自助授权</a> 
            </li>
            <li class="nav-item active"> 
            <a href="change.php">
            <i class="mdi mdi-account-settings-variant"></i> 更换授权</a> 
            </li>
			<li class="nav-item"> 
            <a href="javascript:void(0)" onclick="dail()">
            <i class="mdi mdi-account-box"></i> 购买授权</a> 
            </li>
          </ul>
        </nav>
        
        <div class="sidebar-footer">
          <p class="copyright">Copyright &copy; 2020. <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&amp;uin=<?php echo $kfqq; ?>&amp;site=qq&amp;menu=yes"><?php echo $kfname; ?></a></p>
        </div>
      </div>
      
    </aside>
    <!--End 左侧导航-->
    
    <!--头部信息-->
    <header class="lyear-layout-header">
      
      <nav class="navbar navbar-default">
        <div class="topbar">
          
          <div class="topbar-left">
            <div class="lyear-aside-toggler">
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
            </div>
            <span class="navbar-page-title"> <?php echo $title;?> </span>
          </div>
          
          <ul class="topbar-right">
            <li class="dropdown dropdown-profile">
              <a href="javascript:void(0)" data-toggle="dropdown">
                <span>联系我们 <span class="caret"></span></span>
              </a>
              <ul class="dropdown-menu dropdown-menu-right">
                <li> <a href="http://wpa.qq.com/msgrd?v=3&amp;uin=<?php echo $kfqq; ?>&amp;site=qq&amp;menu=yes"><i class="mdi mdi-delete"></i> 联系作者</a></li>
                <li class="divider"></li>
                <li> <a href="http://wpa.qq.com/msgrd?v=3&amp;uin=<?php echo $kfqq; ?>&amp;site=qq&amp;menu=yes"><i class="mdi mdi-comment-outline"></i> 联系客服</a> </li>
              </ul>
            </li>
    
          </ul>
          
        </div>
      </nav>
      
    </header>
    <!--End 头部信息-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<ul class="nav nav-tabs page-tabs">
<li class="active"> <a href="#!">更换授权</a> </li>

</ul>
<form action="?" method="get">
<div class="tab-content">
<div class="tab-pane active">
<div>

<div class="form-group">
<label for="web_site_title">授权key</label>
<input type="text" id="key" name="key" class="form-control" lay-verType="tips" placeholder="请输入授权key" required/>
</div>
<div class="form-group">
<label for="web_site_title">现机器人QQ</label>
<input type="text" id="qq" name="qq" class="form-control" lay-verType="tips" placeholder="请输入现有的机器人QQ" required/>
</div>
<div class="form-group">
<label for="web_site_title">新机器人QQ</label>
<input type="text" id="user_new" name="user_new" class="form-control" lay-verType="tips" placeholder="请输入要更换成的机器人QQ" required/>
</div>
<hr/>
<button type="submit" onclick="check()" class="btn btn-primary btn-block">点击更换</button>
<?php
//include 'data/config.php';

$user_new=$_GET["user_new"];
$qq=$_GET["qq"];
$key_user=$_GET["key"];

if($qq){
		$SQL = "SELECT * FROM `authorize` WHERE `syskey`='$key_user' and `domain`='$qq'";
		$query=mysqli_query($con,$SQL);
		$row =mysqli_fetch_array($query);
		$id = $row[id];
		$cp = $row[ycp];
		if(mysqli_num_rows($query) == 1)
		{
			$SQL = "SELECT * FROM `authorize` WHERE `domain`='$user_new' and `ycp`='$cp'";
			$query=mysqli_query($con,$SQL);
			if(mysqli_num_rows($query) == 1)
			{
				header('Content-type:text/html;charset=utf-8');
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">要更换的新机器人QQ已存在</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'change.php' });  }});</script>");

			}
			else
			{	
			$sql = "UPDATE `authorize` SET `domain` = '$user_new' WHERE `id` = '$id';";
			mysqli_query($con,$sql);
			header('Content-type:text/html;charset=utf-8');
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">更换授权成功</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'change.php' });  }});</script>");

			}
		}
		else
		{
			header('Content-type:text/html;charset=utf-8');
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">授权key错误或者机器人QQ无授权</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'change.php' });  }});</script>");

		}

}

?>	
<hr/>
</div>
</div>    
</div>
</div>
</form>


<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>说明</h4>
</div>
<div class="card-body">
</p>
1、如果不知道授权key可联系您的代理</p>
2、如果您是用卡密激活的授权，那么key就是您第一次使用的卡密</p>
</div>
</div>
</div>
<script src="/assets/layui.js"></script>
<script type="text/javascript" src="./assets/js/jquery.min.js"></script>
<script type="text/javascript" src="./assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="./assets/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="./assets/js/main.min.js"></script>
</body>
</html>